unit UnitAltaCliente;

{$mode objfpc}{$H+}

interface

uses
  Classes, strings, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  UnitMainForm;

type

  { TFormAltaCliente }

  TFormAltaCliente = class(TForm)
    Button1: TButton;
    Button2: TButton;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  FormAltaCliente: TFormAltaCliente;

implementation

{$R *.lfm}

{ TFormAltaCliente }

procedure TFormAltaCliente.Button1Click(Sender: TObject);
begin
  Close;
end;

procedure TFormAltaCliente.Button2Click(Sender: TObject);
var
  QueryString : string;

begin
  QueryString := 'insert into cliente(cln_apellido, cln_nombre, cln_tipodoc, '
    + 'cln_nro_doc, cln_nro_cliente) values(''' + Edit1.Text + ''', ''' + Edit2.Text
    + ''', ''' + ComboBox1.Text + ''', ' + Edit3.Text + ', ''' + Edit4.Text + ''')';

  MainForm.PQConnection1.ExecuteDirect('BEGIN WORK');
  MainForm.PQConnection1.ExecuteDirect(QueryString);
  MainForm.PQConnection1.ExecuteDirect('COMMIT WORK');

  ShowMessage('ALTA DE CLIENTE EXITOSA!');

  close;
end;

procedure TFormAltaCliente.FormShow(Sender: TObject);
begin
  Edit1.Text := '';
  Edit2.Text := '';
  Edit3.Text := '';
  Edit4.Text := '';
  ComboBox1.Text := '';

  Edit1.SetFocus;
end;

end.

